//
//  PingguViewController.m
//  App-MyFairldy
//
//  Created by 客官大大 on 15/5/23.
//  Copyright (c) 2015年 客官大大. All rights reserved.
//

#import "PingguViewController.h"

@interface PingguViewController ()

@end

@implementation PingguViewController

- (void)viewDidLoad {
    [super viewDidLoad];
//    // Do any additional setup after loading the view.
//   self.view.backgroundColor = [UIColor grayColor];
    
    UIImage * iamg = [UIImage imageNamed:@"vol_24_fullscreen_v2.jpg"];
    UIImageView *ooo = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    ooo.image = iamg;
    [self.view addSubview:ooo];
    UIImageView *vieww = [[UIImageView alloc] init];
    UIImage *image = [UIImage imageNamed:@"iconfont-xin"];
    vieww.image = image;
    vieww.frame = CGRectMake(20, 80, 25, 25);
    [self.view addSubview:vieww];
    UILabel *lable1 = [[UILabel alloc] initWithFrame:CGRectMake(50, 80, 300, 25)];
    lable1.text = @"您的身体每天需要摄入";
    [self.view addSubview:lable1];
    UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake(230, 80, 160, 25)];
    lable.text = [self numv1:_shengao v2:_tizhong v3:_nianl];
    NSString *sss = [self numv1:_shengao v2:_tizhong v3:_nianl];
    lable.textColor = [UIColor redColor];
    [self.view addSubview:lable];
    
    UILabel *lable2 = [[UILabel alloc] initWithFrame:CGRectMake(50, 110, 320, 25)];
    NSString * str = [self num2:_shengao];
    NSLog(@"%@",str);
    if ([str compare:_tizhong] > 0) {
        lable2.text = @"您的体重比较偏低，您的身体在抗议了 ！";
    }else
    {
        lable2.text = @"您的身体有点超重了哦，应注意饮食";
    }
    [self.view addSubview:lable2];
    UIImageView *vieww1 = [[UIImageView alloc] init];
    UIImage *image1 = [UIImage imageNamed:@"iconfont-xin"];
    vieww1.image = image1;
    vieww1.frame = CGRectMake(20, 110, 25, 25);
    [self.view addSubview:vieww1];
    
    
    UIImageView *imageview = [[UIImageView alloc] initWithFrame:CGRectMake(20, 170, 335, 1)];
    imageview.backgroundColor = [UIColor blackColor];
    [self.view addSubview:imageview];
    
    
    UIImageView *imageview4 = [[UIImageView alloc] initWithFrame:CGRectMake(20, 200, 335, 1)];
    imageview4.backgroundColor = [UIColor blackColor];

    [self.view addSubview:imageview4];
    
    UILabel *lal = [[UILabel alloc] initWithFrame:CGRectMake(20, 172, 100, 28)];
    lal.text = @"食物推荐";
    [self.view addSubview:lal];
    
    
    UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(20, 210, 335, 180)];
    view1.backgroundColor = [UIColor whiteColor];
    view1.alpha =0.7;
    [self.view addSubview:view1];
    
    UILabel *labll = [[UILabel alloc] initWithFrame:CGRectMake(10, 5, 100, 30)];
    labll.text = @"减肥计划";
    [view1 addSubview:labll];
    
    UIView *view3 = [[UIView alloc]initWithFrame:CGRectMake(0, 40, 335, 130)];
    view3.backgroundColor = [UIColor grayColor];
    view3.layer.cornerRadius = 15;
    [view1 addSubview:view3];
    
    UILabel *lll = [[UILabel alloc] initWithFrame:CGRectMake(10, 20, 40, 20)];
    lll.text = @"早餐";
    [view3 addSubview:lll];
    
    UILabel *www = [[UILabel alloc] initWithFrame:CGRectMake(10, 60, 40, 20)];
    www.text = @"午餐";
    [view3 addSubview:www];
    
    UILabel *ww = [[UILabel alloc] initWithFrame:CGRectMake(10, 100, 40, 20)];
    ww.text = @"晚餐";
    [view3 addSubview:ww];
    
    UIImageView *imagheviwq = [[UIImageView alloc] initWithFrame:CGRectMake(10, 50, 315, 1)];
    imagheviwq.backgroundColor = [UIColor blackColor];
    [view3 addSubview:imagheviwq];
    
    UIImageView *imagheviwq1 = [[UIImageView alloc] initWithFrame:CGRectMake(10, 90, 315, 1)];
    imagheviwq1.backgroundColor = [UIColor blackColor];
    [view3 addSubview:imagheviwq1];
    
    UIImageView *iiii = [[UIImageView alloc] initWithFrame:CGRectMake(50, 0, 1, 130)];
    iiii.backgroundColor = [UIColor blackColor];
    [view3 addSubview:iiii];
    
    UILabel *zao = [[UILabel alloc] initWithFrame:CGRectMake(60, 20, 250, 20)];
//    zao.backgroundColor = [UIColor redColor];
    zao.textColor = [UIColor blackColor];
//    zao.numberOfLines = NO;

    
    [view3 addSubview:zao];
    
    
    UILabel *zao1 = [[UILabel alloc] initWithFrame:CGRectMake(60, 60, 250, 20)];
//    zao1.backgroundColor = [UIColor redColor];
    
    [view3 addSubview:zao1];
    
    UILabel *zao2 = [[UILabel alloc] initWithFrame:CGRectMake(60, 100, 250, 20)];
//    zao2.backgroundColor = [UIColor redColor];
    
    [view3 addSubview:zao2];
    
    NSString *a = @"2000";
    NSString *aa = @"2300";
    NSString *aaa = @"2400";
    NSString *aaaa = @"2500";
    NSLog(@"%@",sss);
    if ([sss compare:a] < 0) {
        zao.text = @"馒头x1、粥x1、鸡蛋x1、咸菜";
        zao1.text = @"肉类（猪肉最佳）x200g、蔬菜、米饭x1、水果";
        zao2.text = @"米饭x1、汤、蔬菜";
    }else if ([sss compare:a] > 0 && [sss compare:aa] < 0){
    zao.text = @"粥x1、鸡蛋x1、咸菜";
        zao1.text =@"少量肉类x100g、蔬菜、水果（含糖量低）";
        zao2.text = @"蔬菜、水果";
    }else if ([sss compare:aa] > 0 && [sss compare:aaa] < 0){
    zao.text =@"牛奶x1杯、面包x1或者粥x1、馒头x0.5、咸菜";
        zao1.text = @"肉类（鸡肉或鱼）x 100g、蔬菜、米饭x1";
        zao2.text = @"蔬菜、水果（少量）、米饭x0.5";
        
    }else if ([sss compare:aaa] > 0 && [sss compare:aaaa] < 0)
    {
    zao.text = @"牛奶x1杯";
        zao1.text = @"蔬菜、水果（含糖量低）";
        zao2.text = @"少量蔬菜";
    }
    
    
    
    
    UIView *viewww = [[UIView alloc] initWithFrame:CGRectMake(20, 420, 335, 200)];
    viewww.backgroundColor = [UIColor whiteColor];
    viewww.alpha = 0.7;
    viewww.layer.cornerRadius = 20;
    [self.view addSubview:viewww];
    
    UILabel *lablle = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 300, 30)];
    lablle.text = @"常见水果营养解析";
    [viewww addSubview:lablle];
    
    UILabel *xiangjiao = [[UILabel alloc] initWithFrame:CGRectMake(10, 50, 315, 0)];
    xiangjiao.text = @"香蕉：高碳水化合物，高钾含量的一种水果，在水果中热量很高，减肥时不适合大量实用。热量：91大卡";
    xiangjiao.numberOfLines = 0;
    [xiangjiao sizeToFit];
    [viewww addSubview:xiangjiao];
    
    UILabel *xigua = [[UILabel alloc] initWithFrame:CGRectMake(10, xiangjiao.frame.size.height+50, 315, 20)];
    xigua.text = @"西瓜：含水量很高，热量很低的水果，同事含有一定量的钾，对消除水肿有一订作用，适宜减肥期间使用。热量：25大卡";
    xigua.numberOfLines = 0;
    [xigua sizeToFit];
    [viewww addSubview:xigua];
    
    
    
    
    
}

-(NSString *)numv1:(NSString *)v1 v2:(NSString *)v2 v3:(NSString *)v3{
    CGFloat result = 655.0 + 9.563*[v1 floatValue] + 1.85 * [v2 floatValue] - 4.67*[v3 floatValue];
    return [NSString stringWithFormat:@"%.2f卡路里",result];

}
-(NSString *)num2:(NSString *)v1{
    NSInteger result = ([v1 floatValue] - 100 )* 0.9;
    return [NSString stringWithFormat:@"%ld",result];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
